/**
 * fileName: ActivityRecordServiceImpl.java
 * fileTime: 2011-6-18上午11:46:02
 */
package com.bf.xpdd.service.impl;

import java.sql.SQLException;
import java.util.List;

import com.bf.xpdd.domain.ActivityRecordBean;
import com.bf.xpdd.domain.AnalysisDealByDay;
import com.bf.xpdd.domain.AnalysisDealByItem;
import com.bf.xpdd.domain.SiteSeller;
import com.bf.xpdd.exception.BaseException;
import com.bf.xpdd.persistent.iface.DaoActivityRecord;
import com.bf.xpdd.service.ActivityRecordService;

/**
 * 成交记录服务实现
 * @author linmu
 *
 */
public class ActivityRecordServiceImpl implements ActivityRecordService
{

	/**
	 * 成交记录服务DAO
	 */
	private DaoActivityRecord daoActivityRecord;
	
	/**
	 * 成交记录服务注入
	 * @param daoActivityRecord
	 */
	public void setDaoActivityRecord(DaoActivityRecord daoActivityRecord)
	{
		this.daoActivityRecord = daoActivityRecord;
	}
	
	@Override
	public void addActivityRecord(ActivityRecordBean actRecord)
	{
		this.daoActivityRecord.addActivityRecord(actRecord);
	}

	@Override
	public ActivityRecordBean queryActRecordById(long id)
	{
		return this.daoActivityRecord.queryActRecordById(id);
	}

	@Override
	public List<ActivityRecordBean> queryActRecordByItemId(long itemId)
	{
		return this.daoActivityRecord.queryActRecordByItemId(itemId);
	}

	@Override
	public List<ActivityRecordBean> queryActRecordByActId(long actId, int num)
	{
		return this.daoActivityRecord.queryActRecordByActId(actId, num);
	}

	@Override
	public void delActRecordById(long id)
	{
		this.daoActivityRecord.delActRecordById(id);
	}

	@Override
	public void delActRecordByItemId(long itemId)
	{
		this.daoActivityRecord.delActRecordByItemId(itemId);
	}

	@Override
	public void delActRecordByActId(long actId)
	{
		this.daoActivityRecord.delActRecordByActId(actId);
	}

	@Override
	public void modifyActRecordToperByItemId(long toperId, long itemId)
	{
		this.daoActivityRecord.modifyActRecordToperByItemId(toperId, itemId);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public long queryActRecordByItemIdAndNick(long itemId, String nick) throws BaseException 
	{
		try 
		{
			return this.daoActivityRecord.queryActRecordByItemIdAndNick(itemId, nick);
		} 
		catch (SQLException e) 
		{
			throw new BaseException("获取成交记录错误");
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<ActivityRecordBean> findUnsyncDealRecordBySeller(SiteSeller seller) throws BaseException
	{
		try
		{
			return this.daoActivityRecord.queryUnsyncActRecordBySeller(seller);
		}
		catch (SQLException e)
		{
			throw new BaseException("查询未同步购买信息失败");
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void saveSyncStatus(ActivityRecordBean deal) throws BaseException
	{
		try
		{
			this.daoActivityRecord.updateSyncStatus(deal);
		}
		catch (SQLException e)
		{
			throw new BaseException("更新购买信息失败");
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<AnalysisDealByDay> findDealCountByDay(SiteSeller seller, int month) throws BaseException
	{
		try
		{
			return this.daoActivityRecord.queryDealCountByDay(seller, month);
		}
		catch (SQLException e)
		{
			throw new BaseException("查询成交数量失败");
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<AnalysisDealByItem> findDealCountByActivity(long activityId, int month) throws BaseException
	{
		try
		{
			return this.daoActivityRecord.queryDealCountByActivity(activityId, month);
		}
		catch (SQLException e)
		{
			throw new BaseException("查询成交数量失败");
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<AnalysisDealByItem> findDealCountByItem(long itemId, int month) throws BaseException
	{
		try
		{
			return this.daoActivityRecord.queryDealCountByItem(itemId, month);
		}
		catch (SQLException e)
		{
			throw new BaseException("查询成交数量失败");
		}
	}

}
